<!-- ChildComponent.vue -->
<template>
  <lay-card :title="title">
    <ul>
      <li v-for='product in list'>
        {{ product.logmonth }}
      </li>
    </ul>
  </lay-card>
</template>

<script>
import {ref, onMounted, reactive, toRefs} from 'vue'
import {getDataList} from '../api/data'
export default {
  props: {
    title: String,
    content: String,
    modulename: String
  },
  setup(props) {
    const state = reactive({
      list: []
    })
    // 调取api获取数据
    const getNewsList = () => {
      getDataList(props.content).then(res => {
        state.list = res.data.data
      })
    }
    onMounted(getNewsList)
    // ...toRefs()将state里面得对象解构
    return {
      ...toRefs(state),
    };
  }
}
</script>

